// 获取轮播图
$.ajax({
  type: 'get',
  url: '/slides',
  success: function(response) {
    var html = template('slideShowTpl', {data: response})
    $('.bannerLoop').html(html)
    for (var i = 0; i < response.length; i++) {
      let span = $('<span></span>')
      $('.circle').append(span)
    }
    // 初始化轮播图数据
    var swiper = new Swiper('.swiper-container', {
      // 无缝循环
      loop: true,
      //  实时监测,动态更新
      observer: true,
      //  禁止拖动，需要为container加个类 swiper-no-swiping
      noSwiping: true,
      //  自动播放开启
      autoplay: true,
      //  自动播放配置
      autoplay: {
        //  间隔
        delay: 3000,
        //  操作后重新开启自动播放
        disableOnInteraction: false
      },
      //  左右按钮点击
      navigation: {
        nextEl: '.arrow-r',
        prevEl: '.arrow-l',
      },
      //  分页
      pagination: {
        el: '.circle',
        type: 'custom',
        renderCustom: function (swiper, current, total) {
        $('.circle span').eq(current - 1).addClass('circleActive').siblings().removeClass('circleActive')
      },
    }
      })
  }
})
// 最新文章发布
$.ajax({
  type: 'get',
  url: '/posts/lasted',
  success: function(response) {
    let html = template('lastedTpl', {data: response})
    $('.article').html(html)
  }
})
